{% load i18n %}
{% load staticfiles %}

<!DOCTYPE html>
<html lang="en">

<head>
{% block javascript %}{% endblock %}

<title>{% block title %}课后一小时{% endblock %}</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta content="yes" name="apple-mobile-web-app-capable">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		
<link rel="stylesheet" href="/static/login/bootstrap.min.css" />
<link rel="stylesheet" href="/static/login/css/camera.css" />
<link rel="stylesheet" href="/static/login/bootstrap-responsive.min.css" />
<link rel="stylesheet" href="/static/login/matrix-login.css" />
<link href="/static/login/font-awesome.css" rel="stylesheet" />
<script type="text/javascript" src="/static/js/jquery-1.5.1.min.js"></script>
<style>
	a.flip-link.btn.btn-info{
		display: block;
		line-height: 40px;
		font-size: 18px;
	}
	#loginbox { overflow: hidden !important; z-index: 100;  text-align: center;  position: relative; margin-top:20%;}
</style>
</head>
<body>

	<div
		style="width:100%;text-align: center;margin: 0 auto;position: absolute;height:100vh;background-image: url(/static/login/weixin-login.jpg);">
		<div id="loginbox">
			<form action="" method="post" name="loginForm"
				id="loginForm">
				<input type="hidden" name="openid" id="openid" value="{{openid}}"/>
		
				<div class="control-group normal_text">
					<h3>
						<img src="/static/weixin/images/logo-1.png" alt="Logo" />
					</h3>
				</div>
				<div class="control-group">
					<div class="controls">
						<div class="main_input_box">
							<span class="add-on bg_lg">
							<i><img height="37" src="/static/login/user.png" /></i>
							</span><input type="text" name="loginname" id="loginname" value="" placeholder="请输入用户名" />
						</div>
					</div>
				</div>
				<div class="control-group">
					<div class="controls">
						<div class="main_input_box">
							<span class="add-on bg_ly">
							<i><img height="37" src="/static/login/suo.png" /></i>
							</span><input type="password" name="password" id="password" placeholder="请输入密码" value="" />
						</div>
					</div>
				</div>
				<div class="form-actions">
					<a onclick="severCheck();"
							class="flip-link btn btn-info" id="to-recover">登录</a>

					 
				</div>

			</form>


		</div>
	</div>
	
	<script type="text/javascript">
	 
		//服务器校验
		function severCheck(){
			if(check()){
				
				var loginname = $("#loginname").val();
				var password = $("#password").val();
				var openid = $("#openid").val();
				
				$.ajax({
					type: "post",
					url: '/weixin/weixin_login_validate',
			    	data: {openid:openid,loginname:loginname,password:password,tm:new Date().getTime()},
					dataType:'json',
					cache: false,
					success: function(data){
						if("success" == data.result){
							window.location.href="/weixin/personal_center?openid="+openid;
						}else if("usererror" == data.result){
							$("#loginname").tips({
								side : 1,
								msg : "用户名或密码有误",
								bg : '#FF5080',
								time : 15
							});
							$("#loginname").focus();
						}
					},
					error: function(e) {
						console.log(e)
					} 
				});
			}
		}
	

		$(document).keyup(function(event) {
			if (event.keyCode == 13) {
				$("#to-recover").trigger("click");
			}
		});

		function genTimestamp() {
			var time = new Date();
			return time.getTime();
		}

		 

		//客户端校验
		function check() {

			if ($("#loginname").val() == "") {

				$("#loginname").tips({
					side : 2,
					msg : '用户名不得为空',
					bg : '#AE81FF',
					time : 3
				});

				$("#loginname").focus();
				return false;
			} else {
				$("#loginname").val(jQuery.trim($('#loginname').val()));
			}

			if ($("#password").val() == "") {

				$("#password").tips({
					side : 2,
					msg : '密码不得为空',
					bg : '#AE81FF',
					time : 3
				});

				$("#password").focus();
				return false;
			}

			$("#loginbox").tips({
				side : 1,
				msg : '正在登录 , 请稍后 ...',
				bg : '#68B500',
				time : 10
			});

			return true;
		}
 
	</script>
	<script>
		//TOCMAT重启之后 点击左侧列表跳转登录首页 
		if (window != top) {
			top.location.href = location.href;
		}
	</script>

	<script src="/static/js/jquery-1.7.2.js"></script>
	<script src="/static/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="/static/js/jquery.tips.js"></script>
	<script type="text/javascript" src="/static/js/jquery.cookie.js"></script>
	<script type="text/javascript" src="/static/js/myjs/crsf.js"></script>
</body>

</html>
</body></html>